﻿using System;

namespace PropertyExpression.ControllableQuery.Toolkit.Test.Queries
{
    public interface IError1QueryInfo
    {
        string PartNumber { get; }
    }

    public partial class Error1Query// : IQuery<IError1QueryInfo>
    {
        private readonly IInnerPartLinkSwitcher innerPartLinkSwitcher;
        private readonly IParam<Guid> billOfMaterialsHeaderId;
        private readonly IParam<Guid> servicePartsPageId;
        private readonly IParam<Guid> modelPublicationId;

        public Error1Query(
            IParam<Guid> billOfMaterialsHeaderId,
            IParam<Guid> servicePartsPageId,
            IParam<Guid> modelPublicationId,
            IInnerPartLinkSwitcher innerPartLinkSwitcher)
        {
            this.billOfMaterialsHeaderId = billOfMaterialsHeaderId;
            this.servicePartsPageId = servicePartsPageId;
            this.modelPublicationId = modelPublicationId;
            this.innerPartLinkSwitcher = innerPartLinkSwitcher;
        }
    }

    public interface IInnerPartLinkSwitcher
    {
        void AddSubQuery(Action<bool, IParam<string>, IParam<Guid>> action);
    }

    public class WithoutInnerPartLinkSwitcher : IInnerPartLinkSwitcher
    {
        public void AddSubQuery(Action<bool, IParam<string>, IParam<Guid>> action)
        {
            //no-op
        }
    }

    public class WithInnerPartLinkSwitcher : IInnerPartLinkSwitcher
    {
        private readonly bool latestPublicationOnly;
        private readonly IParam<string> languageCode;
        private readonly IParam<Guid> modelId;

        public WithInnerPartLinkSwitcher(
            bool latestPublicationOnly, IParam<string> languageCode, IParam<Guid> modelId)
        {
            this.latestPublicationOnly = latestPublicationOnly;
            this.languageCode = languageCode;
            this.modelId = modelId;
        }

        public void AddSubQuery(Action<bool, IParam<string>, IParam<Guid>> action)
        {
            action(latestPublicationOnly, languageCode, modelId);
        }
    }
}